package com.itheima.d03_udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Client {
    public static void main(String[] args) throws Exception {
        // 创建发送端的客户端对象
        DatagramSocket client= new DatagramSocket();
        //2.创建封装数据的数据包对象
        byte[] sendMsg = "释永信方丈已经追拿归案！！！".getBytes();
        int sendmsgLength = sendMsg.length;
        InetAddress ip = InetAddress.getLocalHost() ;
        int port = 10086;
      DatagramPacket packet = new DatagramPacket(sendMsg, sendmsgLength, ip,port);
//        3.发送数据
        client.send(packet);
        System.out.println("数据已发送");
//        4.释放资源
    client.close();

    }
}
